﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BLL.BusinessClasses;

namespace WebSite.General
{
    public partial class RegistroEmpresa : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button_AgregarEmpresa_Click(object sender, EventArgs e)
        {
            try
            {
                BLL.BusinessClasses.Empresa NuevaEmpresa = new BLL.BusinessClasses.Empresa(this.TextBox_Nombre.Text.Trim(),
                                                                                           this.TextBox_RNC.Text.Trim(),
                                                                                           this.TextBox_Direccion.Text.Trim(),
                                                                                           this.TextBox_Descripcion.Text.Trim(),
                                                                                           this.TextBox_Contacto.Text.Trim(),
                                                                                           this.TextBox_CargoContacto.Text.Trim());
                                
                NuevaEmpresa.Pais = new Pais(Convert.ToInt32(DropDownList_Paises.SelectedValue));
                NuevaEmpresa.Insertar();
                
                NuevaEmpresa.AgregarContacto(BLL.BusinessClasses.Contacto.GetIDByTipoContactoDescripcion("Telefono"),                    
                                             this.TextBox_Telefono.Text.Trim());
                
                if (this.TextBox_EMail.Text.Trim() != null) 
                {
                    NuevaEmpresa.AgregarContacto(BLL.BusinessClasses.Contacto.GetIDByTipoContactoDescripcion("Email"),
                                                 this.TextBox_EMail.Text.Trim());                    
                }
                
                this.Label_NotificacionRegistro.Visible = true;
            }                
            catch (Exception)
            {
                this.Label_MensajeErrorAgregarEmpresa.Visible = true;
            }
        }
    }
}
